package me.zfz.business.dao.impl;

import java.io.Serializable;
import java.util.List;

import me.zfz.base.exception.DaoException;
import me.zfz.business.bean.entity.TNAttachment;
import org.springframework.stereotype.Repository;

import com.mixsmart.utils.StringUtils;

import me.zfz.base.dao.impl.BaseDaoImpl;

/**
 * 附件
 * @author author
 *
 */
@Repository
public class AttachmentDao extends BaseDaoImpl<TNAttachment>{

	@Override
	public boolean delete(Serializable id) throws DaoException {
		boolean is = false;
		if(null != id && StringUtils.isNotEmpty(id.toString())) {
			String[] idArray = id.toString().split(",");
			List<TNAttachment> lists = find(idArray);
			if(null != lists && lists.size()>0) {
				is = super.delete(lists);
				/*if(super.delete(lists)) {
					is = true;
					String rootDir = InitSysConfig.getInstance().getValue("root.dir");
					for (TNAttachment att : lists) {
						String filePath = rootDir+att.getFilePath();
						FileUtil.deleteFile(filePath);
					}
				}*/
			}
		}
		return is;
	}

}
